const util = require('util')
const chalk = require('chalk')
const { merge } = require('webpack-merge')
const commonConfig = require('./webpack.common')
const development = require('./webpack.dev')
const productionConfig = require('./webpack.prod')

const initialConfig = (env) => {
  if (env) {
    console.log(chalk.green(`Env is ${env}`))
  } else {
    console.log(chalk.rgb(251, 174, 40)('There is not a value of Env here. The default value of Env is \'production\''))
  }
  switch (env) {
    case 'development':
      return merge(commonConfig, development)
    case 'production':
    default:
      return merge(commonConfig, productionConfig)
  }
}
module.exports = initialConfig(process.env.mode || process.env.NODE_ENV)
